/*
 * NextAction.java
 *
 * Created on June 22, 2005, 8:33 PM
 *
 * To change this template, choose Tools | Options and locate the template under
 * the Source Creation and Management node. Right-click the template and choose
 * Open. You can then make changes to the template in the Source Editor.
 */
package com.bff.mpd.musicjukebox.lib.actions;

import com.bff.mpd.musicjukebox.ui.MainFrameBase;
import com.bff.mpd.utils.Utils;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.KeyStroke;

/**
 *
 * @author Bill
 */
public class MinimizeAction extends AbstractAction {
    private boolean minimized;
    
    /** Creates a new instance of StopAction */
    public MinimizeAction() {
        super(Utils.getMessage("ACTION_MINIMIZE_NAME"));
        
        putValue(Action.SMALL_ICON,new ImageIcon(getClass().getResource("/resources/mpd/minimize.png")));
        putValue(Action.MNEMONIC_KEY,new Integer('M'));
        putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("ctrl M"));
        putValue(Action.SHORT_DESCRIPTION, Utils.getMessage("ACTION_MINIMIZE_SHORT_DESC"));
    }
    
    @Override
    public void actionPerformed(ActionEvent evt) {
        if(isMinimized()) {
            putValue(Action.SMALL_ICON,new ImageIcon(getClass().getResource("/resources/mpd/minimize.png")));
            MainFrameBase.maximizePanel();
            setMinimized(false);
        } else {
            putValue(Action.SMALL_ICON,new ImageIcon(getClass().getResource("/resources/mpd/maximize.png")));
            MainFrameBase.minimizePanel();
            setMinimized(true);
        }
    }

    /**
     * @return the minimized
     */
    public boolean isMinimized() {
        return minimized;
    }

    /**
     * @param minimized the minimized to set
     */
    public void setMinimized(boolean minimized) {
        this.minimized = minimized;
    }

}
